package cn.mikeal.bean;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class WebLogBean implements WritableComparable<WebLogBean> {
	private boolean is_valid;
	private String remote_user;
	private String remote_addr;
	private String time_local;
	private String request;
	private String status;
	private String body_bytes_sent;
	private String http_referer;
	private String http_user_agent;

	public WebLogBean() {
		super();
		// TODO Auto-generated constructor stub
	}

	public WebLogBean(boolean is_valid, String remote_user, String remote_addr, String time_local, String request,
			String status, String body_bytes_sent, String http_referer, String http_user_agent) {
		super();
		this.is_valid = is_valid;
		this.remote_user = remote_user;
		this.remote_addr = remote_addr;
		this.time_local = time_local;
		this.request = request;
		this.status = status;
		this.body_bytes_sent = body_bytes_sent;
		this.http_referer = http_referer;
		this.http_user_agent = http_user_agent;
	}

	public boolean isIs_valid() {
		return is_valid;
	}

	public void setIs_valid(boolean is_valid) {
		this.is_valid = is_valid;
	}

	public String getRemote_user() {
		return remote_user;
	}

	public void setRemote_user(String remote_user) {
		this.remote_user = remote_user;
	}

	public String getRemote_addr() {
		return remote_addr;
	}

	public void setRemote_addr(String remote_addr) {
		this.remote_addr = remote_addr;
	}

	public String getTime_local() {
		return time_local;
	}

	public void setTime_local(String time_local) {
		this.time_local = time_local;
	}

	public String getRequest() {
		return request;
	}

	public void setRequest(String request) {
		this.request = request;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getBody_bytes_sent() {
		return body_bytes_sent;
	}

	public void setBody_bytes_sent(String body_bytes_sent) {
		this.body_bytes_sent = body_bytes_sent;
	}

	public String getHttp_referer() {
		return http_referer;
	}

	public void setHttp_referer(String http_referer) {
		this.http_referer = http_referer;
	}

	public String getHttp_user_agent() {
		return http_user_agent;
	}

	public void setHttp_user_agent(String http_user_agent) {
		this.http_user_agent = http_user_agent;
	}

	@Override
	public String toString() {
		return time_local + "\001" + remote_addr + body_bytes_sent + "\001" + http_referer + "\001" + http_user_agent;
	}

	@Override
	public int compareTo(WebLogBean o) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		this.is_valid = in.readBoolean();
		this.remote_user = in.readUTF();
		this.remote_addr = in.readUTF();
		this.time_local = in.readUTF();
		this.request = in.readUTF();
		this.status = in.readUTF();
		this.body_bytes_sent = in.readUTF();
		this.http_referer = in.readUTF();
		this.http_user_agent = in.readUTF();

	}

	@Override
	public void write(DataOutput out) throws IOException {
		out.writeBoolean(is_valid);
		out.writeUTF(remote_user);
		out.writeUTF(remote_addr);
		out.writeUTF(time_local);
		out.writeUTF(request);
		out.writeUTF(status);
		out.writeUTF(body_bytes_sent);
		out.writeUTF(http_referer);
		out.writeUTF(http_user_agent);

	}

}
